package com.yj.question_project.domain;

import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.Set;

/**
 * @Auther: starsky1
 * @Date: 2024/01/10 20:37
 * @Description: todo
 */
@Data
public class MetroLine implements Serializable {
    /**
     * 主键id
     */
    private Long id;
    private String lineId;
    private String lineName;

    private double costTime;

    private double avgStaTime;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    /**
     * 删除标记 0 未删除 1 已删除
     */
    private Integer isDel;

    /**
     * 线路颜色
     */
    private String lineColor;

    /**
     * qp_metro_line
     */
    private static final long serialVersionUID = 1L;

    public double getAvgStaTime() {
        return costTime/(stations.size()-1);
    }

    private List<VNode> stations = new ArrayList<>();

    public MetroLine(String lineId, String lineName, String lineColor) {
        this.lineId = lineId;
        this.lineName = lineName;
        this.lineColor = lineColor;
    }

    public void addStation(VNode node) {
        if(!stations.contains(node)) {
            stations.add(node);
        }
    }

    @Override
    public boolean equals(Object o) {
        if(this == o) {
            return true;
        }
        if(o instanceof MetroLine) {
            MetroLine oLine = (MetroLine) o;
            if(oLine == null) {
                return false;
            }
            if(this.lineId != null && this.lineId.equals(oLine.lineId)) {
                return true;
            }
        }
        return false;
    }

    @Override
    public int hashCode() {
        return this.lineId.hashCode();
    }

    @Override
    public String toString() {
        return lineName;
    }
}
